/*
 * @author: sanbao
 * @Date: 2022-07-25 15:10:21
 */
import request from "@/utils/request";
/**
 * 
 * @param pagenum 
 * @param pagesize 
 * @returns 
 */
const getcategorieslist = (pagenum: number, pagesize: number) => {
    // http://47.108.251.106:8881/api/private/v1/categories?type=3&pagenum=1&pagesize=5
    return request({
        url: `categories?type=3&pagenum=${pagenum}&pagesize=${pagesize}`,
        method: 'GET',
    })
}
/**
 * 
 * @returns 
 */
const getcategoriestype = () => {
    return request({
        // http://47.108.251.106:8881/api/private/v1/categories?type=2
        url: 'categories?type=2',
        method: 'GET',
    })
}

/**
 * 
 * @param data 
 * @returns 
 */
const addprivatelist = (data: any) => {
    let ceng = 0
    let num = 0
    if (!data.roleDesc) {
        ceng = 0
        num = 0
    } else if (data.roleDesc.length == 1) {
        ceng = 1
        num = data.roleDesc[0]
    } else {
        ceng = 2
        num = data.roleDesc[1]

    }
    let obj = {
        cat_level: ceng,
        cat_name: data.roleName,
        cat_pid: num
    }
    return request({
        // http://47.108.251.106:8881/api/private/v1/categories
        url: 'categories',
        method: 'POST',
        data: obj
    })
}
/**
 * 删除
 * @param id 
 * @returns 
 */
const deletecategorieslist = (id: number) => {
    return request({
        url: `categories/${id}`,
        method: 'DELETE',
    })
}
export default {
    getcategorieslist,
    getcategoriestype,
    addprivatelist,
    deletecategorieslist
}